<?php
declare (strict_types=1);

namespace app\common\model;

class UserBreed extends Base
{
    protected $name = 'user_breed';

    public static function getMaxNum($id)
    {
        $now = parent::where(['id' => $id])->field('id, count')->find();
        $next = parent::where('id', '>', $id)->order('id asc')->field('id, count')->find();
        if (!$next || $now->count <= 0) {
            $max_num = 0;
        } else {
            $max_num = ceil(($next->count - $now->count) / $now->count);
        }

        return $max_num;
    }
}
